/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package be.vdab.servlets;

import be.vdab.dao.VoorstellingDAO;
import be.vdab.entiteit.Reservatie;
import java.io.IOException;
import java.util.List;
import java.util.Set;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 *
 * @author tom.vanpoucke
 */
@WebServlet(urlPatterns="/welkom.htm", name="welkomservlet")
public class WelkomServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
    private static final String VIEW = "/WEB-INF/JSP/welkom.jsp";
    private final VoorstellingDAO voorstellingDAO = new VoorstellingDAO();

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        HttpSession session = request.getSession(false);
        boolean ok = false;
        if( session != null){
            Set<Reservatie> mandje = (Set<Reservatie>) session.getAttribute("mandje");
            if(mandje == null || mandje.isEmpty()){
            }
            else{                
                ok = true;
                request.setAttribute("ok", ok);
            }
        }
        List genres = voorstellingDAO.findGenres();
        request.setAttribute("genres", genres);
        RequestDispatcher dispatcher = request.getRequestDispatcher(VIEW);
        dispatcher.forward(request, response);
    }

}